package tv.acgn.advertisement.publish.action;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import tv.acgn.advertisement.publish.exception.AbstractAdPubException;
import tv.acgn.advertisement.publish.service.UserService;
import tv.acgn.advertisement.publish.vo.user.AdUserRequestVO;
import tv.acgn.advertisement.publish.vo.user.AdUserResponseVO;

/**
 * @author : junG
 * @program : advertisement-ad-pub-action
 * @description : 用户内容服务 分发器
 * @date : 2019-06-02 02:01
 **/

@RestController
@Slf4j
public class UserAction {

    @Autowired
    private UserService userService;

    @GetMapping(value = "/user/{id}")
    public AdUserResponseVO getUser(@PathVariable(value = "id") String userId) throws AbstractAdPubException {
        return userService.getUser(userId);
    }

    @GetMapping(value = "/user/find")
    public AdUserResponseVO findUser(@RequestBody AdUserRequestVO requestVO) throws AbstractAdPubException {
        return userService.findUser(requestVO);
    }

    @PostMapping(value = "/user")
    public AdUserResponseVO addUser(@RequestBody AdUserRequestVO requestVO) throws AbstractAdPubException {
        return userService.addUser(requestVO);
    }

    @PutMapping(value = "/user")
    public AdUserResponseVO updateUser(@RequestBody AdUserRequestVO requestVO) throws AbstractAdPubException {
        return userService.updateUser(requestVO);
    }

    @DeleteMapping(value = "/user/{id}")
    public AdUserResponseVO deleteUser(@PathVariable(value = "id") String userId) throws AbstractAdPubException {
        return userService.deleteUser(userId);
    }
}
